﻿_spBodyOnLoadFunctionNames.push('SetAndDisableInputs');

function SetAndDisableInputs() {
    var titleElement = getElementByAttributeValue('title', 'Title');
    var guidElement = getElementByAttributeValue('title', 'ObjectGuid');
    var qsTitle = getQueryString('Title');
    titleElement.value = qsTitle.replace(/%20/g,' ');
    titleElement.readOnly = true;
    titleElement.style.background = '#e6e6e6';
    var qsObjectGuid = getQueryString('ObjectGuid');
    guidElement.value = qsObjectGuid;
    guidElement.readOnly = true;
    guidElement.style.background = '#e6e6e6';
}

function getElementByAttributeValue(attribute, value) {
    var allElements = document.getElementsByTagName('*');
    for (var i = 0; i < allElements.length; i++) {
        if (allElements[i].getAttribute(attribute) == value) {
            return allElements[i];
        }
    }
}

function getQueryString(sVar) {
    urlStr = window.location.search.substring(1);
    sv = urlStr.split('&');
    for (i=0;i< sv.length;i++) {
        ft = sv [i].split('=');
        if (ft[0] == sVar) {
            return ft[1];
        }
    }
}